Public Class DocTypeForm

    Public Property DocElemName() As String
        Get
            Dim txt As String = txtName.Text
            Return IIf(txt.Length > 0, txt, Nothing)
        End Get
        Set(ByVal value As String)
            txtName.Text = value
        End Set
    End Property

    Public Property PublicId() As String
        Get
            Dim txt As String = txtPublicId.Text
            Return IIf(txt.Length > 0, txt, Nothing)
        End Get
        Set(ByVal value As String)
            txtPublicId.Text = value
        End Set
    End Property

    Public Property SystemId() As String
        Get
            Dim txt As String = txtSystemId.Text
            Return IIf(txt.Length > 0, txt, Nothing)
        End Get
        Set(ByVal value As String)
            txtSystemId.Text = value
        End Set
    End Property

    Public Property Subset() As String
        Get
            Dim txt As String = txtSubset.Text
            Return IIf(txt.Length > 0, txt, Nothing)
        End Get
        Set(ByVal value As String)
            txtSubset.Text = value
        End Set
    End Property

    Private Sub txtName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtName.TextChanged

        If txtName.Focused Then
            If txtName.Text.Length > 0 Then
                DocTypeChange()
            Else
                txtDocType.Clear()
                ErrorProvider1.SetError(txtName, "name expected")
            End If
        End If
    End Sub

    Private Sub DocTypeChange()

        'txtdoctype.Text = "<!DOCTYPE "& txtname.Text &">"
        txtDocType.Text = Dtd.Preview(DocElemName, PublicId, SystemId, Subset)

    End Sub

    Private Sub txtPublicId_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtPublicId.TextChanged

        If txtPublicId.Focused Then
            DocTypeChange()
        End If
    End Sub

    Private Sub txtSystemId_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSystemId.TextChanged

        If txtSystemId.Focused Then
            DocTypeChange()
        End If
    End Sub

    Private Sub txtSubset_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtSubset.TextChanged

        If txtSubset.Focused Then
            DocTypeChange()
        End If
    End Sub
End Class